package io.gitee.twoke.generator.spring.boot;

import io.gitee.twoke.generator.engine.GenerateEngine;
import io.gitee.twoke.generator.spring.boot.actuate.endpoint.GenerateEngineEndpoint;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan("io.gitee.twoke.generator")
@ConditionalOnProperty(prefix = "spring.generator", name = "enable", havingValue = "true")
public class EndpointAutoConfiguration {

    @Bean
    @ConditionalOnAvailableEndpoint
    public GenerateEngineEndpoint processEngineEndpoint(GenerateEngine engine) {
        return new GenerateEngineEndpoint(engine);
    }
}